package com.zktravel.listener;

import javax.annotation.Resource;

import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

import com.zktravel.service.category.PlCategoryService;
import com.zktravel.util.RedisCacheUtil;

@Component
public class StartListener implements ApplicationListener<ContextRefreshedEvent>{

	@Resource
	private RedisCacheUtil<Object> redisCache;
	@Resource
	private PlCategoryService plCategoryService;
	
	@Override
	public void onApplicationEvent(ContextRefreshedEvent event) {
//		if(event.getApplicationContext().getParent() == null){
			
			/*List<PlCategoryVO> categoryList = plCategoryService.getAllCategory();
			
			if(null == redisCache.getCacheList(CacheConstant.CATEGORY_LIST)){
				redisCache.setCacheList(CacheConstant.CATEGORY_LIST, categoryList);
			}
			
			Map<Long, PlCategoryVO> categoryMap = categoryList.stream().collect(Collectors.toMap(PlCategoryVO::getId, Function.identity()));
			
			if(null == redisCache.getCacheLongMap(CacheConstant.CATEGORY_MAP)){
				redisCache.setCacheLongMap(CacheConstant.CATEGORY_MAP, categoryMap);
			}*/
			
//		}	
		
	}

}
